home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / usstates.c < prev    next >
C/C++ Source or Header  |  1988-12-14  |  2KB  |  85 lines

  1. /* usstates.c, 9/3/88, d.c.oshel */
  2.  
  3. #include "fafnir.h"
  4. #include <stdio.h>
  5.  
  6. /* U.S. Postal Service 2-letter state and territory abbreviations */
  7.  
  8. static char *states[] = {
  9.     "   Foreign",
  10.     "AL Alabama",
  11.     "AK Alaska",
  12.     "AZ Arizona",
  13.     "AR Arkansas",
  14.     "CA California",
  15.     "CO Colorado",
  16.     "CT Connecticut",
  17.     "DE Delaware",
  18.     "DC Dist. of Columbia",
  19.     "FL Florida",
  20.     "GA Georgia",
  21.     "GU Guam",
  22.     "HI Hawaii",
  23.     "ID Idaho",
  24.     "IL Illinois",
  25.     "IN Indiana",
  26.     "IA Iowa",
  27.     "KS Kansas",
  28.     "KY Kentucky",
  29.     "LA Louisiana",
  30.     "ME Maine",
  31.     "MD Maryland",
  32.     "MA Massachusetts",
  33.     "MI Michigan",
  34.     "MN Minnesota",
  35.     "MS Mississippi",
  36.     "MO Missouri",
  37.     "MT Montana",
  38.     "NE Nebraska",  /* NOT "NB", according to U.S. Post Office! */
  39.     "NV Nevada",
  40.     "NH New Hampshire",
  41.     "NJ New Jersey",
  42.     "NM New Mexico",
  43.     "NY New York",
  44.     "NC North Carolina",
  45.     "ND North Dakota",
  46.     "OH Ohio",
  47.     "OK Oklahoma",
  48.     "OR Oregon",
  49.     "PA Pennsylvania",
  50.     "PR Puerto Rico",
  51.     "RI Rhode Island",
  52.     "SC South Carolina",
  53.     "SD South Dakota",
  54.     "TN Tennesee",
  55.     "TX Texas",
  56.     "UT Utah",
  57.     "VT Vermont",
  58.     "VI Virgin Islands",
  59.     "VA Virginia",
  60.     "WA Washington",
  61.     "DC Washington, D.C.",
  62.     "WV West Virginia",
  63.     "WI Wisconsin",
  64.     "WY Wyoming",
  65.     NULL
  66. };
  67.  
  68.  
  69. /* field validater */
  70. int vstate( char *p, int x, int y, int len )
  71. {
  72.     char **q;
  73.  
  74.     if (*p != ' ')  /* assistance flag */
  75.     {
  76.     for ( q = states; *q != NULL; q++ )
  77.     {
  78.         if ( memicmp( p, *q, 2 ) == 0 )
  79.             return (1);
  80.     }}
  81.     memcpy( p, states[ select(x,y,states,SIZE(states)-1) ], len );
  82.     return (1);    
  83. }
  84.  
  85.